// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.vehicles;

public final class LightbarLightsMode {
    private long startTime = 0L;
    private int light = 0;
    private final int modeMax = 3;
    private int mode = 0;

    public int get() {
        return this.mode;
    }

    public void set(int v) {
        if (v > 3) {
            this.mode = 3;
        } else if (v < 0) {
            this.mode = 0;
        } else {
            this.mode = v;
            if (this.mode != 0) {
                this.start();
            }
        }
    }

    public void start() {
        this.startTime = System.currentTimeMillis();
    }

    public void update() {
        long _long = System.currentTimeMillis() - this.startTime;
        switch (this.mode) {
            case 1:
                _long %= 1000L;
                if (_long < 50L) {
                    this.light = 0;
                } else if (_long < 450L) {
                    this.light = 1;
                } else if (_long < 550L) {
                    this.light = 0;
                } else if (_long < 950L) {
                    this.light = 2;
                } else {
                    this.light = 0;
                }
                break;
            case 2:
                _long %= 1000L;
                if (_long < 50L) {
                    this.light = 0;
                } else if (_long < 250L) {
                    this.light = 1;
                } else if (_long < 300L) {
                    this.light = 0;
                } else if (_long < 500L) {
                    this.light = 1;
                } else if (_long < 550L) {
                    this.light = 0;
                } else if (_long < 750L) {
                    this.light = 2;
                } else if (_long < 800L) {
                    this.light = 0;
                } else {
                    this.light = 2;
                }
                break;
            case 3:
                _long %= 300L;
                if (_long < 25L) {
                    this.light = 0;
                } else if (_long < 125L) {
                    this.light = 1;
                } else if (_long < 175L) {
                    this.light = 0;
                } else if (_long < 275L) {
                    this.light = 2;
                } else {
                    this.light = 0;
                }
                break;
            default:
                this.light = 0;
        }
    }

    public int getLightTexIndex() {
        return this.light;
    }

    public boolean isEnable() {
        return this.mode != 0;
    }
}
